#include "EventFd.h"
#include <chrono>
#include <iostream>
#include <functional>
#include <thread>

using std::cout;
using std::endl;
using std::bind;
using std::thread;

class MyTask
{
public:
    void process()
    {
        cout << "MyTask is running!!!" << endl;
    }
};

int main(int argc, char *argv[])
{
    MyTask task;
    EventFd ef(bind(&MyTask::process, &task));
    thread th(bind(&EventFd::start, &ef));//th子线程

    int cnt = 10;
    while(cnt--)
    {
        std::this_thread::sleep_for(std::chrono::seconds(1));
        ef.wakeup();//主线程执行唤醒操作
    }

    ef.stop();
    th.join();
    return 0;
}

